function e(e, t, o) {
    return t in e ? Object.defineProperty(e, t, {
        value: o,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = o, e;
}

var t = require("../../wxParse/wxParse.js"), o = require("../../requests/request.js"), n = require("../../utils/util.js"), i = getApp();

Page({
    data: {
        newid: 0,
        title: "",
        newstype: 1,
        categoryid: 0,
        article: "",
        newsinfo: null,
        count: 0,
        comment: [],
        hotcomment: [],
        isshowcomment: !1,
        isshowhotcomment: !1,
        isyiche: !0,
        pagesource: ""
    },
    onLoad: function(o) {
        var n, i = this;
        i.loadingshow();
        var s = "";
        o.pagesource && (s = o.pagesource), this.setData({
            newsid: o.newsid,
            newstype: o.newstype,
            pagesource: s
        }), t.emojisInit("[]", "/wxParse/emojis/", (n = {
            "00": "00.gif",
            "01": "01.gif",
            "02": "02.gif",
            "03": "03.gif",
            "04": "04.gif",
            "05": "05.gif",
            "06": "06.gif",
            "07": "07.gif",
            "08": "08.gif",
            "09": "09.gif"
        }, e(n, "09", "09.gif"), e(n, "10", "10.gif"), e(n, "11", "11.gif"), e(n, "12", "12.gif"), 
        e(n, "13", "13.gif"), e(n, "14", "14.gif"), e(n, "15", "15.gif"), e(n, "16", "16.gif"), 
        e(n, "17", "17.gif"), e(n, "18", "18.gif"), e(n, "19", "19.gif"), n));
        var a = o.newsid;
        this.GetNewsDetails(a), a.toString().length <= 7 ? (i.setData({
            isyiche: !1
        }), this.getNewscomment(a)) : this.getImportantnewscomment(a);
    },
    GetNewsDetails: function(e) {
        var n = this;
        console.log(e), o.getNewsDetail(e, function(e) {
            var o = e.Data;
            e.Status > 0 && (console.log(o), t.wxParse("article", "html", o.content, n, 5), 
            n.setData({
                newsinfo: o,
                title: o.title
            }));
        }, function(e) {
            console.log(" getNewsDetail error.");
        }, function(e) {
            console.log(" getNewsDetail complete."), n.loadinghide();
        });
    },
    getImportantnewscomment: function(e) {
        console.log(e);
        var t = this;
        o.getImportantnewscomment(e, 1, 11, function(e) {
            var o = e.data;
            if (o && o.list && o.list.length > 0) for (var i = 0; i < o.list.length; i++) o.list[i].createtime = n.formatTimeToString(o.list[i].createtime);
            o && t.setData({
                hotcomment: o.list,
                isshowhotcomment: !(null == o.list || void 0 == o.list || o.list.length < 1)
            });
        }, function(e) {
            console.log(" getImportantnewscomment-hot error.");
        }, function(e) {
            console.log(" getImportantnewscomment-hot-1 complete."), t.loadinghide();
        }), o.getImportantnewscomment(e, 0, 11, function(e) {
            var o = e.data;
            if (console.log(o && o.list && o.list.length > 0), o && o.list && o.list.length > 0) for (var i = 0; i < o.list.length; i++) o.list[i].createtime = n.formatTimeToString(o.list[i].createtime);
            o && (t.setData({
                comment: o.list,
                count: o.count,
                isshowcomment: !(null == o.list || void 0 == o.list || o.list.length < 1)
            }), console.log(t.data));
        }, function(e) {
            console.log(" getImportantnewscomment error.");
        }, function(e) {
            console.log(" getImportantnewscomment complete."), t.loadinghide();
        });
    },
    getNewscomment: function(e) {
        console.log(e);
        var t = this;
        o.getNewscomment(e, 0, 1, function(e) {
            console.log(e);
            var o = e.List;
            if (o && o.length > 0) for (var i = 0; i < o.length; i++) o[i].PublishTime = n.formatTimeToString(o[i].PublishTime);
            o && t.setData({
                hotcomment: o,
                isshowhotcomment: !(null == o || void 0 == o || o.length < 1)
            });
        }, function(e) {
            console.log(" getNewscomment error.");
        }, function(e) {
            console.log(" getNewscomment-1 complete."), t.loadinghide();
        }), o.getNewscomment(e, 0, 0, function(e) {
            console.log(e);
            var o = e.List;
            if (o && o.length > 0) for (var i = 0; i < o.length; i++) o[i].PublishTime = n.formatTimeToString(o[i].PublishTime);
            o && t.setData({
                comment: o,
                count: e.Count,
                isshowcomment: !(null == o || void 0 == o || o.length < 1)
            }), console.log(t.data);
        }, function(e) {
            console.log(" getNewscomment error.");
        }, function(e) {
            console.log(" getNewscomment complete."), t.loadinghide();
        });
    },
    onReady: function() {},
    loadingshow: function() {
        wx.canIUse("showLoading") && wx.showLoading(), wx.canIUse("showNavigationBarLoading") && wx.showNavigationBarLoading();
    },
    loadinghide: function() {
        wx.canIUse("hideLoading") && wx.hideLoading(), wx.canIUse("hideNavigationBarLoading") && wx.hideNavigationBarLoading();
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        wx.stopPullDownRefresh();
    },
    onReachBottom: function() {
        console.log("onReachBottom");
    },
    onShareAppMessage: function() {
        return {
            title: "专业的汽车资讯",
            path: "/pages/newsDetail/newsDetail?newid=" + this.data.newid + "&pagesource=wxshare"
        };
    },
    returnBtn: function() {
        i.gotoIndex();
    }
});